<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ad_media_user', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('媒体广告主账号');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('media_id')->comment('媒体id')->unsigned()->default(0);
            $table->string('user_name', 50)->comment('帐号')->default('');
            $table->string('password', 512)->comment('密码')->default('');
            $table->string('alias', 50)->comment('别名')->default('');
            $table->tinyInteger('type')->comment('账号类型 1普通 2管家')->unsigned()->default(0);
            $table->integer('owner_id')->comment('管家账号id')->unsigned()->default(0);
            $table->bigInteger('advertiser_id')->comment('媒体广告主id')->unsigned()->default(0);
            $table->string('cert_domain', 255)->comment('认证域名')->default('');
            $table->integer('marketing_app_id')->comment('媒体开发者应用id')->unsigned()->default(0);
            $table->integer('update_time')->comment('更新时间')->unsigned()->default(0);
            $table->string('token', 50)->comment('账号token')->default('');

            $table->index('media_id');
            $table->index('user_name');
            $table->index('advertiser_id');
            $table->index('owner_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ad_media_user');
    }
};
